home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.db.pro;
-
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.StringBufferInputStream;
- import java.util.Vector;
- import symjava.lang.Bignum;
- import symjava.sql.Date;
- import symjava.sql.SQLException;
- import symjava.sql.Time;
- import symjava.sql.Timestamp;
-
- public class ProjBinder {
- Vector _links;
- int _id;
- RelationView _rv;
- boolean _inSetDataNotify;
- boolean _enabled;
- boolean _columnIsWriteable;
- public static final int DEFAULTSCALE = 0;
- public static final int SETBLANKTODEFAULT = 0;
- public static final int SETBLANKTONULL = 1;
- public static final int SETBLANKTOEMPTY = 2;
-
- ProjBinder(int colID, RelationView rv, boolean enabled) {
- this._id = colID;
- this._rv = rv;
- this._links = new Vector();
- this._inSetDataNotify = false;
- this._enabled = enabled;
- this._columnIsWriteable = true;
-
- try {
- RelationViewMetaData md = rv.getMetaData();
- int type = md.getColumnType(colID);
- if (type == -1 || type == -2 || type == -3 || type == -4 || type == 1111) {
- this._columnIsWriteable = false;
- }
-
- } catch (SQLException var6) {
- this._columnIsWriteable = false;
- }
- }
-
- void addLink(ProjLink link) {
- if (!this._links.contains(link)) {
- this._links.addElement(link);
- }
-
- }
-
- boolean bindsExist() {
- return this._links.size() > 0;
- }
-
- void removeLink(Object link) {
- this._links.removeElement(link);
- }
-
- void removeAllLinks() {
- this._links.removeAllElements();
- }
-
- void notifyDataChange() {
- if (this._enabled && !this._inSetDataNotify) {
- for(int i = 0; i < this._links.size(); ++i) {
- ProjLink link = (ProjLink)this._links.elementAt(i);
- link.notifyDataChange(this);
- }
- }
-
- }
-
- boolean notifySetData() throws SQLException {
- boolean setDataResult = true;
- if (this._enabled) {
- this._inSetDataNotify = true;
-
- for(int i = 0; i < this._links.size(); ++i) {
- ProjLink link = (ProjLink)this._links.elementAt(i);
- if (!link.notifySetData(this)) {
- setDataResult = false;
- break;
- }
- }
-
- this._inSetDataNotify = false;
- }
-
- return setDataResult;
- }
-
- void enable(boolean enable) {
- this._enabled = enable;
- }
-
- public boolean isWritable() throws SQLException {
- return this._rv.isCurrentRecordWritable() && this._columnIsWriteable;
- }
-
- public boolean isReadable() throws SQLException {
- return this._rv.isCurrentRecordReadable();
- }
-
- public String getColumnName() throws SQLException {
- RelationViewMetaData md = this._rv.getMetaData();
- return md.getColumnName(this._id);
- }
-
- public RelationView getRelationView() throws SQLException {
- return this._rv;
- }
-
- public boolean isNull() throws SQLException {
- return this._rv.isNull(this._id);
- }
-
- public String getString() throws SQLException {
- return this._rv.getString(this._id);
- }
-
- public boolean getBoolean() throws SQLException {
- return this._rv.getBoolean(this._id);
- }
-
- public byte getByte() throws SQLException {
- return this._rv.getByte(this._id);
- }
-
- public short getShort() throws SQLException {
- return this._rv.getShort(this._id);
- }
-
- public int getInt() throws SQLException {
- return this._rv.getInt(this._id);
- }
-
- public long getLong() throws SQLException {
- return this._rv.getLong(this._id);
- }
-
- public float getFloat() throws SQLException {
- return this._rv.getFloat(this._id);
- }
-
- public double getDouble() throws SQLException {
- return this._rv.getDouble(this._id);
- }
-
- public Bignum getBignum(int scale) throws SQLException {
- return this._rv.getBignum(this._id, scale);
- }
-
- public byte[] getBytes() throws SQLException {
- return this._rv.getBytes(this._id);
- }
-
- public Date getDate() throws SQLException {
- return this._rv.getDate(this._id);
- }
-
- public Time getTime() throws SQLException {
- return this._rv.getTime(this._id);
- }
-
- public Timestamp getTimestamp() throws SQLException {
- return this._rv.getTimestamp(this._id);
- }
-
- public InputStream getAsciiStream() throws SQLException {
- return this._rv.getAsciiStream(this._id);
- }
-
- public InputStream getUnicodeStream() throws SQLException {
- return this._rv.getUnicodeStream(this._id);
- }
-
- public InputStream getBinaryStream() throws SQLException {
- return this._rv.getBinaryStream(this._id);
- }
-
- public String getStringValue(int scale) throws SQLException, IOException {
- RelationViewMetaData md = this._rv.getMetaData();
- int columnType = md.getColumnType(this._id);
- return this.getStringValue(columnType, scale, false);
- }
-
- public String getStringValue(int scale, boolean processBinaryData) throws SQLException, IOException {
- RelationViewMetaData md = this._rv.getMetaData();
- int columnType = md.getColumnType(this._id);
- return this.getStringValue(columnType, scale, processBinaryData);
- }
-
- public String getStringValue() throws SQLException, IOException {
- RelationViewMetaData md = this._rv.getMetaData();
- int columnType = md.getColumnType(this._id);
- return this.getStringValue(columnType, 0, false);
- }
-
- public String getStringValue(boolean processBinaryData) throws SQLException, IOException {
- RelationViewMetaData md = this._rv.getMetaData();
- int columnType = md.getColumnType(this._id);
- return this.getStringValue(columnType, 0, processBinaryData);
- }
-
- public String getStringValue(String columnTypeName, int scale) throws SQLException, IOException {
- int columnType = RelationView.sqlTypeConvert(columnTypeName);
- return this.getStringValue(columnType, scale, false);
- }
-
- public String getStringValue(String columnTypeName, int scale, boolean processBinaryData) throws SQLException, IOException {
- int columnType = RelationView.sqlTypeConvert(columnTypeName);
- return this.getStringValue(columnType, scale, processBinaryData);
- }
-
- public String getStringValue(int columnType, int scale) throws SQLException, IOException {
- return this.getStringValue(columnType, scale, false);
- }
-
- public String getStringValue(int columnType, int scale, boolean processBinaryData) throws SQLException, IOException {
- int length = scale;
- if (scale == 0) {
- RelationViewMetaData md = this._rv.getMetaData();
- scale = md.getScale(this._id);
- length = md.getColumnDisplaySize(this._id);
- }
-
- String value = "";
- if (!this.isNull()) {
- switch (columnType) {
- case -7:
- value = String.valueOf(this.getBoolean());
- break;
- case -6:
- value = String.valueOf(this.getByte());
- break;
- case -5:
- value = String.valueOf(this.getLong());
- break;
- case -4:
- if (processBinaryData) {
- InputStream lvbIs = this.getBinaryStream();
- value = RelationView.binaryStreamtoString(lvbIs, length);
- } else {
- value = "<Binary Data>";
- }
- break;
- case -3:
- if (processBinaryData) {
- byte[] vbinb = new byte[length];
- vbinb = this.getBytes();
- value = RelationView.binaryArraytoString(vbinb);
- } else {
- value = "<Binary Data>";
- }
- break;
- case -2:
- if (processBinaryData) {
- byte[] binb = new byte[length];
- binb = this.getBytes();
- value = RelationView.binaryArraytoString(binb);
- } else {
- value = "<Binary Data>";
- }
- break;
- case -1:
- InputStream lvcIs = this.getAsciiStream();
- value = RelationView.asciiStreamtoString(lvcIs);
- break;
- case 0:
- value = "";
- break;
- case 1:
- value = this.getString();
- break;
- case 2:
- Bignum n = this.getBignum(scale);
- if (n != null) {
- value = String.valueOf(n);
- }
- break;
- case 3:
- Bignum d = this.getBignum(scale);
- if (d != null) {
- value = String.valueOf(d);
- }
- break;
- case 4:
- value = String.valueOf(this.getInt());
- break;
- case 5:
- value = String.valueOf(this.getShort());
- break;
- case 6:
- value = this.getString();
- break;
- case 7:
- value = this.getString();
- break;
- case 8:
- value = this.getString();
- break;
- case 12:
- value = this.getString();
- break;
- case 91:
- Date dt = this.getDate();
- if (dt != null) {
- value = dt.toString();
- }
- break;
- case 92:
- Time tm = this.getTime();
- if (tm != null) {
- value = tm.toString();
- }
- break;
- case 93:
- Timestamp ts = this.getTimestamp();
- if (ts != null) {
- value = ts.toString();
- }
- break;
- case 1111:
- if (processBinaryData) {
- InputStream uniIs = this.getUnicodeStream();
- value = RelationView.binaryStreamtoString(uniIs, length);
- } else {
- value = "<Other Data Type>";
- }
- break;
- default:
- value = this.getString();
- }
- }
-
- return value;
- }
-
- public void setNull(int sqlType) throws SQLException {
- this._rv.setNull(this._id, sqlType);
- }
-
- public void setBoolean(boolean x) throws SQLException {
- this._rv.setBoolean(this._id, x);
- }
-
- public void setByte(byte x) throws SQLException {
- this._rv.setByte(this._id, x);
- }
-
- public void setShort(short x) throws SQLException {
- this._rv.setShort(this._id, x);
- }
-
- public void setInt(int x) throws SQLException {
- this._rv.setInt(this._id, x);
- }
-
- public void setLong(long x) throws SQLException {
- this._rv.setLong(this._id, x);
- }
-
- public void setFloat(float x) throws SQLException {
- this._rv.setFloat(this._id, x);
- }
-
- public void setDouble(double x) throws SQLException {
- this._rv.setDouble(this._id, x);
- }
-
- public void setBignum(Bignum x) throws SQLException {
- this._rv.setBignum(this._id, x);
- }
-
- public void setString(String x) throws SQLException {
- this._rv.setString(this._id, x);
- }
-
- public void setBytes(byte[] x) throws SQLException {
- this._rv.setBytes(this._id, x);
- }
-
- public void setDate(Date x) throws SQLException {
- this._rv.setDate(this._id, x);
- }
-
- public void setTime(Time x) throws SQLException {
- this._rv.setTime(this._id, x);
- }
-
- public void setTimestamp(Timestamp x) throws SQLException {
- this._rv.setTimestamp(this._id, x);
- }
-
- public void setAsciiStream(InputStream x, int length) throws SQLException {
- this._rv.setAsciiStream(this._id, x, length);
- }
-
- public void setUnicodeStream(InputStream x, int length) throws SQLException {
- this._rv.setUnicodeStream(this._id, x, length);
- }
-
- public void setBinaryStream(InputStream x, int length) throws SQLException {
- this._rv.setBinaryStream(this._id, x, length);
- }
-
- public void setValueFromString(String data, int scale, int treatBlankAsNull) throws SQLException, IOException {
- RelationViewMetaData md = this._rv.getMetaData();
- int columnType = md.getColumnType(this._id);
- this.setValueFromString(data, columnType, scale, treatBlankAsNull);
- }
-
- public void setValueFromString(String data) throws SQLException, IOException {
- RelationViewMetaData md = this._rv.getMetaData();
- int columnType = md.getColumnType(this._id);
- this.setValueFromString(data, columnType, 0, 0);
- }
-
- public void setValueFromString(String data, int treatBlankAsNull) throws SQLException, IOException {
- RelationViewMetaData md = this._rv.getMetaData();
- int columnType = md.getColumnType(this._id);
- this.setValueFromString(data, columnType, 0, treatBlankAsNull);
- }
-
- public void setValueFromString(String data, String columnTypeName, int scale) throws SQLException, IOException {
- int columnType = RelationView.sqlTypeConvert(columnTypeName);
- this.setValueFromString(data, columnType, scale, 0);
- }
-
- public void setValueFromString(String data, String columnTypeName, int scale, int treatBlankAsNull) throws SQLException, IOException {
- int columnType = RelationView.sqlTypeConvert(columnTypeName);
- this.setValueFromString(data, columnType, scale, treatBlankAsNull);
- }
-
- public void setValueFromString(String data, int columnType, int scale, int treatBlankAsNull) throws SQLException, IOException {
- if (data == null || data.compareTo("") == 0) {
- data = RelationView.processEmptyStringData(data, this._rv, this._id, columnType, treatBlankAsNull);
- if (data == null) {
- this.setNull(columnType);
- return;
- }
- }
-
- switch (columnType) {
- case -7:
- boolean b = new Boolean(data);
- this.setBoolean(b);
- return;
- case -6:
- byte ti = (byte)Integer.valueOf(data);
- this.setByte(ti);
- return;
- case -5:
- long l = Long.valueOf(data);
- this.setFloat((float)l);
- return;
- case -4:
- int lvblen = data.length();
- StringBufferInputStream lvbbsstm = new StringBufferInputStream(data);
- this.setBinaryStream(lvbbsstm, lvblen);
- return;
- case -3:
- byte[] vbarray = new byte[data.length()];
- data.getBytes(0, data.length(), vbarray, 0);
- this.setBytes(vbarray);
- return;
- case -2:
- byte[] barray = new byte[data.length()];
- data.getBytes(0, data.length(), barray, 0);
- this.setBytes(barray);
- return;
- case -1:
- int lvclen = data.length();
- StringBufferInputStream lvcbsstm = new StringBufferInputStream(data);
- this.setAsciiStream(lvcbsstm, lvclen);
- return;
- case 0:
- this.setNull(columnType);
- return;
- case 1:
- this.setString(data);
- return;
- case 2:
- if (scale == 0) {
- Bignum n = new Bignum(data);
- this.setBignum(n);
- return;
- }
-
- Bignum n = new Bignum(data, scale);
- this.setBignum(n);
- return;
- case 3:
- if (scale == 0) {
- Bignum dec = new Bignum(data);
- this.setBignum(dec);
- return;
- }
-
- Bignum dec = new Bignum(data, scale);
- this.setBignum(dec);
- return;
- case 4:
- int i = Integer.valueOf(data);
- this.setInt(i);
- return;
- case 5:
- short si = (short)Integer.valueOf(data);
- this.setShort(si);
- return;
- case 6:
- this.setString(data);
- return;
- case 7:
- this.setString(data);
- return;
- case 8:
- this.setString(data);
- return;
- case 12:
- this.setString(data);
- return;
- case 91:
- Date dt = null;
- dt = Date.valueOf(data);
- this.setDate(dt);
- return;
- case 92:
- Time t = null;
- t = Time.valueOf(data);
- this.setTime(t);
- return;
- case 93:
- Timestamp ts = null;
- ts = Timestamp.valueOf(data);
- this.setTimestamp(ts);
- return;
- case 1111:
- int unilen = data.length();
- StringBufferInputStream unibsstm = new StringBufferInputStream(data);
- this.setBinaryStream(unibsstm, unilen);
- return;
- default:
- this.setString(data);
- }
- }
- }
-